package com.whalehearing.tingyou.api.controller.hearing;

import com.whalehearing.tingyou.common.annotation.DataSource;
import com.whalehearing.tingyou.common.annotation.Log;
import com.whalehearing.tingyou.common.core.controller.BaseController;
import com.whalehearing.tingyou.common.core.domain.AjaxResult;
import com.whalehearing.tingyou.common.enums.BusinessType;
import com.whalehearing.tingyou.common.enums.DataSourceType;
import com.whalehearing.tingyou.domain.HearingSyncUserProfile;
import com.whalehearing.tingyou.service.IHearingSyncUserProfileService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;

/**
 * 测前初评同步个人资料Controller
 *
 * @author zengjun-qxm
 * @date 2024-09-29
 */
@Api(tags = "Api测前初评同步个人资料管理")
@RestController
@RequestMapping("/api/hearing/special")
public class ApiHearingSyncUserProfileController extends BaseController {
    @Autowired
    private IHearingSyncUserProfileService syncUserProfileService;

    /**
     * 获取测前初评同步个人资料详细信息
     */
    @ApiOperation("根据-userId-获取测前初评同步个人资料详细信息")
    @GetMapping(value = "/getSpecialByUserId/{userId}")
    public AjaxResult getSpecialByUserId(@PathVariable("userId") Long userId) {
        return success(syncUserProfileService.getSpecialByUserId(userId));
    }

    /**
     * 新增测前初评同步个人资料
     */
    @ApiOperation("新增修改测前初评同步个人资料接口")
    @Log(title = "测前初评同步个人资料", businessType = BusinessType.INSERT)
    @PostMapping("/addAndUpdate")
    public AjaxResult addAndUpdate(@RequestBody HearingSyncUserProfile hearingSyncUserProfile) {
        return syncUserProfileService.addAndUpdate(hearingSyncUserProfile);
    }

    /**
     * 删除测前初评同步个人资料
     */
    @ApiOperation("删除测前初评同步个人资料")
    @Log(title = "测前初评同步个人资料", businessType = BusinessType.DELETE)
    @DeleteMapping("/{initialValuationSpecialIds}")
    public AjaxResult remove(@PathVariable Long[] initialValuationSpecialIds) {
        return toAjax(syncUserProfileService.removeByIds(Arrays.asList(initialValuationSpecialIds)));
    }
}
